<?php
/**
 *   Kaltura Browser - components/com_kaltura/models/configuration.php
 *   Author: Juan Dapena Paz (juan@bittingbits.com)
 *   Copyright (C) 2011 Bitting Bits S.L.
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
defined('_JEXEC') or die('Restricted access');

jimport('joomla.application.component.model');
class KalturaModelConfiguration extends JModel
{
    function __construct() {
        parent::__construct();
    }
    
    function getConfiguration() {
        $query = 'select * from #__Kaltura_configuration';
        $this->_db->setQuery($query);
        return $this->_db->loadObject();
    }
    
    function setConfiguration($configuration=null) {
        // if $configuration is null, the $configuration will be restored to default values
        $query = 'update #__Kaltura_configuration set ';
        if ($configuration != null) {
            $query .= 'remote_sync='.$configuration->remote_sync;
            $query .= ', details_freehtml="'.$configuration->details_freehtml.'"';
        } else {
            $query .= 'remote_sync=0';
            $query .= ', details_freehtml=""';
        }
        $this->_db->setQuery($query);
        echo $this->_db->getQuery();
        $this->_db->query();
    }
}
?>
